/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/

var w=Object.create;var u=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var g=e=>u(e,"__esModule",{value:!0});var m=(e,t)=>{g(e);for(var r in t)u(e,r,{get:t[r],enumerable:!0})},O=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!v.call(e,n)&&n!=="default"&&u(e,n,{get:()=>t[n],enumerable:!(r=k(t,n))||r.enumerable});return e},b=e=>O(g(u(e!=null?w(P(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);m(exports,{default:()=>f});var s=b(require("obsidian"));function d(e,t){let r=Object.keys(t).map(n=>C(e,n,t[n]));return r.length===1?r[0]:function(){r.forEach(n=>n())}}function C(e,t,r){let n=e[t],i=e.hasOwnProperty(t),o=r(n);return n&&Object.setPrototypeOf(o,n),Object.setPrototypeOf(a,o),e[t]=a,c;function a(...p){return o===n&&e[t]===a&&c(),o.apply(this,p)}function c(){e[t]===a&&(i?e[t]=n:delete e[t]),o!==n&&(o=n,Object.setPrototypeOf(a,n||Function))}}var h,f=class extends s.Plugin{async onload(){h=d(s.Workspace.prototype,{openLinkText(t){return function(r,n,i,o){if(i)return t&&t.apply(this,[r,n,i,o]);let a=V(r),c=!1;return app.workspace.iterateAllLeaves(p=>{let l=p.getViewState();l.type==="markdown"&&l.state?.file===a.path&&(app.workspace.setActiveLeaf(p,{focus:!0}),c=!0)}),c||(c=t&&t.apply(this,[r,n,i,o])),A(a),c}}})}onunload(){h()}};function A(e){let t=app.metadataCache.getCache(e.path),r=app.workspace.getActiveViewOfType(s.MarkdownView);if(e.heading){let n=t.headings.find(i=>i.heading===e.heading);n&&r.editor.setCursor(n.position.start.line)}else if(e.block){let n=t.blocks[e.block];n&&r.editor.setCursor(n.position.start.line)}}function V(e){let t=e.match(/\^(.*)$/),r=t?t[1]:void 0;e=e.replace(/(\^.*)$/,"");let n=e.match(/#(.*)$/),i=n?n[1]:void 0;return e=e.replace(/(#.*)$/,""),{path:app.metadataCache.getFirstLinkpathDest((0,s.getLinkpath)(e),app.workspace.getActiveFile()?.path)?.path??e,heading:i,block:r}}
